package com.ruoyi.blsj.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.blsj.domain.BlsjBgsjzl;
import com.ruoyi.blsj.service.IBlsjBgsjzlService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报告事件资料Controller
 * 
 * @author ruoyi
 * @date 2023-10-09
 */
@Controller
@RequestMapping("/blsj/bgsjzl")
public class BlsjBgsjzlController extends BaseController
{
    private String prefix = "blsj/bgsjzl";

    @Autowired
    private IBlsjBgsjzlService blsjBgsjzlService;

    @RequiresPermissions("blsj:bgsjzl:view")
    @GetMapping()
    public String bgsjzl()
    {
        return prefix + "/bgsjzl";
    }

    /**
     * 查询报告事件资料列表
     */
    @RequiresPermissions("blsj:bgsjzl:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BlsjBgsjzl blsjBgsjzl)
    {
        startPage();
        List<BlsjBgsjzl> list = blsjBgsjzlService.selectBlsjBgsjzlList(blsjBgsjzl);
        return getDataTable(list);
    }

    /**
     * 导出报告事件资料列表
     */
    @RequiresPermissions("blsj:bgsjzl:export")
    @Log(title = "报告事件资料", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BlsjBgsjzl blsjBgsjzl)
    {
        List<BlsjBgsjzl> list = blsjBgsjzlService.selectBlsjBgsjzlList(blsjBgsjzl);
        ExcelUtil<BlsjBgsjzl> util = new ExcelUtil<BlsjBgsjzl>(BlsjBgsjzl.class);
        return util.exportExcel(list, "报告事件资料数据");
    }

    /**
     * 新增报告事件资料
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存报告事件资料
     */
    @RequiresPermissions("blsj:bgsjzl:add")
    @Log(title = "报告事件资料", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BlsjBgsjzl blsjBgsjzl)
    {
        return toAjax(blsjBgsjzlService.insertBlsjBgsjzl(blsjBgsjzl));
    }

    /**
     * 修改报告事件资料
     */
    @RequiresPermissions("blsj:bgsjzl:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        BlsjBgsjzl blsjBgsjzl = blsjBgsjzlService.selectBlsjBgsjzlById(id);
        mmap.put("blsjBgsjzl", blsjBgsjzl);
        return prefix + "/edit";
    }

    /**
     * 修改保存报告事件资料
     */
    @RequiresPermissions("blsj:bgsjzl:edit")
    @Log(title = "报告事件资料", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BlsjBgsjzl blsjBgsjzl)
    {
        return toAjax(blsjBgsjzlService.updateBlsjBgsjzl(blsjBgsjzl));
    }

    /**
     * 删除报告事件资料
     */
    @RequiresPermissions("blsj:bgsjzl:remove")
    @Log(title = "报告事件资料", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(blsjBgsjzlService.deleteBlsjBgsjzlByIds(ids));
    }
}
